package com.xjgzinfo.usdp.service.impl;

import com.xjgzinfo.usdp.domain.BladeVisualGlobal;
import com.xjgzinfo.usdp.repository.BladeVisualGlobalRepository;
import com.xjgzinfo.usdp.service.BladeVisualGlobalService;
import com.xjgzinfo.usdp.service.dto.BladeVisualGlobalDTO;
import com.xjgzinfo.usdp.service.mapper.BladeVisualGlobalMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

/**
 * Service Implementation for managing {@link BladeVisualGlobal}.
 */
@Service
@Transactional
public class BladeVisualGlobalServiceImpl implements BladeVisualGlobalService {

    private final Logger log = LoggerFactory.getLogger(BladeVisualGlobalServiceImpl.class);

    private final BladeVisualGlobalRepository bladeVisualGlobalRepository;

    private final BladeVisualGlobalMapper bladeVisualGlobalMapper;

    public BladeVisualGlobalServiceImpl(BladeVisualGlobalRepository bladeVisualGlobalRepository, BladeVisualGlobalMapper bladeVisualGlobalMapper) {
        this.bladeVisualGlobalRepository = bladeVisualGlobalRepository;
        this.bladeVisualGlobalMapper = bladeVisualGlobalMapper;
    }

    @Override
    public BladeVisualGlobalDTO save(BladeVisualGlobalDTO bladeVisualGlobalDTO) {
        log.debug("Request to save BladeVisualGlobal : {}", bladeVisualGlobalDTO);
        BladeVisualGlobal bladeVisualGlobal = bladeVisualGlobalMapper.toEntity(bladeVisualGlobalDTO);
        bladeVisualGlobal = bladeVisualGlobalRepository.save(bladeVisualGlobal);
        return bladeVisualGlobalMapper.toDto(bladeVisualGlobal);
    }

    @Override
    @Transactional(readOnly = true)
    public Page<BladeVisualGlobalDTO> findAll(Pageable pageable) {
        log.debug("Request to get all BladeVisualCategories");
        return bladeVisualGlobalRepository.findAll(pageable)
                .map(bladeVisualGlobalMapper::toDto);
    }


    @Override
    @Transactional(readOnly = true)
    public Optional<BladeVisualGlobalDTO> findOne(Long id) {
        log.debug("Request to get BladeVisualGlobal : {}", id);
        return bladeVisualGlobalRepository.findById(id)
                .map(bladeVisualGlobalMapper::toDto);
    }

    @Override
    public void delete(Long id) {
        log.debug("Request to delete BladeVisualGlobal : {}", id);
        bladeVisualGlobalRepository.deleteById(id);
    }
}
